<?php
//	ini_set("display_errors","1");
//	ERROR_REPORTING(E_ALL);

if ( isset($_GET['page']) && $_GET['page'] == '' ) {
  $_GET['page'] = 'index.htm';
}
$hash_frag = isset($_GET['_escaped_fragment_']) ? htmlentities($_GET['_escaped_fragment_'], ENT_QUOTES, 'UTF-8') : false;
if ( isset($hash_frag) ) {
  if ($hash_frag == '') {
    $_GET['page'] = 'index.htm';
  } else {
    $parts = explode ('=', $hash_frag);
    $key = $parts[0];
    $value = $parts[1];
    if ($key == 'wiki') {
      $_GET['page'] = $value.".htm";
    } else if ($key == 'api') {
      $_GET['page'] = $value.".html";
    } else {
      $_GET['page'] = 'index.htm';
    }
  }
}

function get_title () {
  $is_wiki = substr($_GET['page'], -4) === '.htm';
  $segments = explode ('/', $_GET['page']);

  for ($i = 0; $i < count ($segments) ; $i++) {
    $segments[$i] = htmlentities ($segments[$i]);
  }

  if (count ($segments) == 2) {
    // package content
    if ($is_wiki) {
      return $segments[0];
    } else {
      // api description: <element-name> -- <package-name>
      return basename ($segments[1], ".html") . ' &ndash; ' . $segments[0];
    }
  }

  return  "Valadoc.org - Stays crunchy. Even in milk.";
}

?>
<html>
  <head>
    <meta charset="UTF-8">
    <meta itemprop="image" content="http://valadoc.org/images/preview.png">
    <meta name="fragment" content="!">
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="theme-color" content="#403757">
    <meta property="og:description" content="The canonical source for Vala API references.">
    <meta property="og:image" content="http://valadoc.org/images/preview.png">
    <meta property="og:title" content="<?php echo get_title (); ?>">
    <meta property="og:type" content="website">
    <title><?php echo get_title (); ?></title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400|Droid+Serif:400|Roboto+Mono:400,500,700,400italic">
    <link rel="stylesheet" href="/styles/main.css" type="text/css">
    <link rel="apple-touch-icon" href="/images/icon.png" />
    <link rel="shortcut icon" href="images/favicon.ico">
  </head>
  <body>
    <nav>
      <div id="search-box">
        <input id="search-field" type="text" placeholder="Search" autocompletion="off" autosave="search" /><img id="search-field-clear" src="/images/clean.svg" />
      </div>
      <a class="title" href="/index.htm"><img alt="Valadoc" src="images/logo.svg"/></a>
      <span class="subtitle">Stays crunchy, even in milk.</span>
      <div id="links">
        <ul>
          <li><a href="https://wiki.gnome.org/Projects/Vala/Tutorial" target="_blank">Tutorial</a></li>
          <li><a href="templates/markup.htm">Markup</a></li>
          <li><a href="https://wiki.gnome.org/Projects/Vala" target="_blank">About Vala</a></li>
          <li><a href="templates/about.htm">About Valadoc</a></li>
        </ul>
      </div>
    </nav>
    <div id="sidebar">
      <ul class="navi_main" id="search-results"></ul>
      <div id="navigation-content">
        <noscript>
          <?php @readfile ($_GET['page'] . '.navi.tpl'); ?>
        </noscript>
      </div>
    </div>
    <div id="content-wrapper">
      <div id="content">
        <noscript>
        <?php @readfile ($_GET['page'] . '.content.tpl'); ?>
        </noscript>
      </div>
      <div id="comments" />

      <div class="site_footer">
      <!-- Generated by <a href="http://www.valadoc.org/">Valadoc</a> -->
      </div>
    </div>
  <script type="text/javascript" src="/scripts/jquery.min.js"></script>
  <script type="text/javascript" src="/scripts/jquery.ba-hashchange.min.js"></script>
  <script type="text/javascript" src="/scripts/wtooltip.js"></script>
  <script type="text/javascript" src="/scripts/valadoc.js"></script>
  <script type="text/javascript" src="/scripts/main.js"></script>
  </body>
</html>
